/*
 * @Description: 
 * @Author: fhw
 * @Date: 2022-12-03 15:42:29
 */
import { Injectable } from '@nestjs/common';
import { MailerService } from '@nestjs-modules/mailer';
import mailTemplates, { MailState } from 'src/common/templates/mail';
import { throwHttp } from 'src/utlis';

@Injectable()
export class EmailService {
    constructor(private readonly mailerService: MailerService) { }
    /**
     * 邮件发送
     */
    public async example(data: MailState) {
        try {
            const datas = await this.mailerService
                .sendMail({
                    to: '1129691449@qq.com',
                    subject: '爷爷，有孙子给你来邮件啦',
                    html: mailTemplates(data),
                })
            console.log(datas);
            return '发送成功';
        } catch (error) {
            throwHttp(error.message)
        }
    }
}